package com.frame.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.frame.dao.AccountDao;
import com.frame.entity.Account;
import com.frame.service.AccountService;

/*
 * @Service 标识这是一个service层实现
 * @Transactional用于事务控制，将事务定位在service层
 */

@Service
public class AccountServiceImpl extends service implements AccountService {

	@Autowired
	private AccountDao accountDao;
	
	@Override
	public boolean verify(String username, String password) {
		
		Account account = accountDao.read(username);
		
		System.out.println(account.getPassword());
		
		if(password.equals(account.getPassword())) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public Account read(String username, String password) {
		Account account = accountDao.read(username);
		if(account == null || !password.equals(account.getPassword())){
			account = null;
		}
		return account;
	}

	@Override
	public Account read(Integer id) {
		Account account = accountDao.read(id);
		return account;
	}

}
